Open
Conversation
wolfv
pushed a commit
that referenced
this pull request
Nov 11, 2025
This commit adds brace expansion support to the shell, implementing
a strict subset of bash's brace expansion functionality.
Supported features:
- Comma-separated lists: {a,b,c} → a b c
- Numeric sequences: {1..10} → 1 2 3 4 5 6 7 8 9 10
- Character sequences: {a..z} → a b c ... z
- Reverse sequences: {10..1} → 10 9 8 7 6 5 4 3 2 1
- Step sequences: {1..10..2} → 1 3 5 7 9
- Reverse step sequences: {10..1..2} → 10 8 6 4 2
- Empty elements: {a,,b} → a b
- Quoted braces don't expand: "{a,b,c}" → {a,b,c}
Implementation details:
- Added BRACE_EXPANSION grammar rule to grammar.pest
- Added BraceExpansion enum to parser.rs with List and Sequence variants
- Added WordPart::BraceExpansion variant
- Implemented expand_braces() and expand_sequence() functions
- Added comprehensive test suite in brace_expansion.sh
The implementation is a strict subset of bash, ensuring compatibility
while keeping the implementation simple and maintainable.
Fixes #242
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I am looking into two issues:
{1..5}should expand to1 2 3 4 5, also in word parts. This already works for globs in deno-task-shell, so it's an extension. Should follow the rules of bash (first brace extension, then globs, for example)."linux-64" == linux*should use pattern matching (and not glob expansion). If a glob is detected on the right hand side of a binary operation like this, then it's used as a pattern to evaluate against the string on the left hand side. We can just use theglobthat is already in use for this, but we need to prevent the current expansion and return a pattern.